package com.acwing.partition45;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/5/23 16:09
 */
public class AC4441谎牛计数_前缀和 {

    private static final int N = 1010;
    private static int[] s = new int[N];
    private static Node[] ope = new Node[N];
    private static int n;

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = nextInt();
        for (int i = 1; i <= n; i++) ope[i] = new Node(next().charAt(0), nextInt());
        Arrays.sort(ope, 1, n + 1);
        for (int i = 1; i <= n; i++) {
            s[i] = s[i - 1];
            if (ope[i].op == 'L') s[i]++;
        }
        int ans = n;
        for (int i = n, r = 0; i > 0; i--) {
            int j = i, t = 0;
            while (j > 0 && ope[j].x == ope[i].x) {
                if (ope[j].op == 'G') t++;
                j--;
            }
            ans = Math.min(ans, s[j] + r);
            r += t;
            i = j + 1;
        }
        writer.println(ans);
        writer.flush();
    }

    private static class Node implements Comparable<Node> {
        private int x;
        private char op;

        public Node(char op, int x) {
            this.x = x;
            this.op = op;
        }

        @Override
        public int compareTo(Node o) {
            if (x != o.x) return Integer.compare(x, o.x);
            return Character.compare(op, o.op);
        }
    }

    private static String next() throws IOException {
        tokenizer.nextToken();
        return tokenizer.sval;
    }

    private static int nextInt() throws IOException {
        tokenizer.nextToken();
        return (int) tokenizer.nval;
    }
}
